package bakaLevel;

import java.util.HashMap;
import java.util.Map;

import pluginMain.BAKACraft;
import pluginMain.Configer;

public class BAKALevel {
	private Configer cLevelConfig;
	private Configer cUserLevels;
	private Configer cMonsterExp;
	private final String CONST_CONFIG_FILE = "BAKALevel.yml";
	private final String CONST_CONFIG_DATA = "PlayerLevelData.yml";
	public static BAKALevel instance;
	public PlayerLevelModel modelInstance;
	public HashMap<String, Integer> MonsterExpList = new HashMap<String, Integer>();
	public HashMap<String, PlayerLevelReader> PlayerInstance = new HashMap<String, PlayerLevelReader>();

	@SuppressWarnings("unchecked")
	public BAKALevel() {
		instance = this;
		// for sub class

		// initialization user infomation here
		// storage user infomation in file
		cLevelConfig = new Configer(BAKACraft.instance, "BAKALevel", CONST_CONFIG_FILE);
		// read model first
		modelInstance = new PlayerLevelModel();
		// create instance
		cUserLevels = new Configer(BAKACraft.instance, "BAKALevel", CONST_CONFIG_DATA);
		// final is user level
		cMonsterExp = new Configer(BAKACraft.instance, "BAKALevel", "MonsterExpList.yml");
		// load all monster exp into mem
		MonsterExpList.putAll((Map<? extends String, ? extends Integer>) cMonsterExp.getMapList("MonsterExp"));
	}

	public Configer getConfigInstance() {
		return cLevelConfig;
	}

	public Configer getUserExpInstance() {
		return cUserLevels;
	}

	public void AddPlayerInstance(String UserName) {
		PlayerInstance.put(UserName, new PlayerLevelReader(UserName));
	}

	public PlayerLevelReader GetPlayerInstance(String UserName) {
		return PlayerInstance.get(UserName);
	}

}
